RAIS  3.2
C:/Projekte/RAIS/dataaccesslayertest/CommonClasses/FunctionRoleAttributeTest.cs
Go to the documentation of this file.
00001 using System;
00002 using System.Collections.Generic;
00003 using System.Text;
00004 using NUnit.Framework;
00005 using RAIS.Common.UserManagement;
00006 using RAIS.DataAccessLayer;
00007 
00008 namespace RAIS.DataAccessLayerTest.CommonClasses
00009 {
00010         [TestFixture]
00011         public class FunctionRoleAttributeTest
00012         {
00013                 private string expectedCategoryName = "Test Category";
00014                 private string expectedSubcategoryName = "Test Subcategory";
00015                 private string expectedMaskName = "Test Mask";
00016                 private bool expectedAccessView = true;
00017                 private bool expectedAccessAdd = true;
00018                 private bool expectedAccessEdit = true;
00019                 private bool expectedAccessDelete = true;
00020 
00021                 private FunctionRole.Category expectedCategory = new FunctionRole.Category();
00022                 private FunctionRole.Subcategory expectedSubcategory = new FunctionRole.Subcategory();
00023                 private Mask expectedMask = new Mask();
00024                 private FunctionRoleAttribute functionRoleAttribute = new FunctionRoleAttribute();
00025 
00026                 [SetUp]
00027                 public void Init()
00028                 {
00029                         this.expectedCategory.Name = this.expectedCategoryName;
00030                         this.expectedSubcategory.Name = this.expectedSubcategoryName;
00031                         this.expectedMask.Name = this.expectedMaskName;
00032 
00033                         this.functionRoleAttribute.Category = this.expectedCategory;
00034                         this.functionRoleAttribute.Subcategory = this.expectedSubcategory;
00035                         this.functionRoleAttribute.Mask = this.expectedMask;
00036                         this.functionRoleAttribute.AccessView = this.expectedAccessView;
00037                         this.functionRoleAttribute.AccessAdd = this.expectedAccessAdd;
00038                         this.functionRoleAttribute.AccessEdit = this.expectedAccessEdit;
00039                         this.functionRoleAttribute.AccessDelete = this.expectedAccessDelete;
00040                 }
00041                 [Test]
00042                 public void GetCategory()
00043                 {
00044                         // Test 
00045                         Assert.AreEqual(this.expectedCategory, this.functionRoleAttribute.Category);
00046                 }
00047                 [Test]
00048                 public void GetSubcategory()
00049                 {
00050                         // Test 
00051                         Assert.AreEqual(this.expectedSubcategory, this.functionRoleAttribute.Subcategory);
00052                 }
00053                 [Test]
00054                 public void GetMask()
00055                 {
00056                         // Test 
00057                         Assert.AreEqual(this.expectedMask, this.functionRoleAttribute.Mask);
00058                 }
00059                 [Test]
00060                 public void GetAccessView()
00061                 {
00062                         // Test 
00063                         Assert.IsTrue(this.functionRoleAttribute.AccessView);
00064                 }
00065                 [Test]
00066                 public void GetAccessAdd()
00067                 {
00068                         // Test 
00069                         Assert.IsTrue(this.functionRoleAttribute.AccessAdd);
00070                 }
00071                 [Test]
00072                 public void GetAccessEdit()
00073                 {
00074                         // Test 
00075                         Assert.IsTrue(this.functionRoleAttribute.AccessEdit);
00076                 }
00077                 [Test]
00078                 public void GetAccessDelete()
00079                 {
00080                         // Test 
00081                         Assert.IsTrue(this.functionRoleAttribute.AccessDelete);
00082                 }
00083                 [Test]
00084                 public void SetCategory()
00085                 {
00086                         // Preparation
00087                         FunctionRole.Category expectedNewCategory = new FunctionRole.Category();
00088                         expectedNewCategory.Name = "New Test Category";
00089 
00090                         // Test 
00091                         this.functionRoleAttribute.Category = expectedNewCategory;
00092 
00093                         // Check
00094                         Assert.AreEqual(expectedNewCategory, this.functionRoleAttribute.Category);
00095                 }
00096                 [Test]
00097                 public void SetSubcategory()
00098                 {
00099                         // Preparation
00100                         FunctionRole.Subcategory expectedNewSubcategory = new FunctionRole.Subcategory();
00101                         expectedNewSubcategory.Name = "New Test Subcategory";
00102 
00103                         // Test 
00104                         this.functionRoleAttribute.Subcategory = expectedNewSubcategory;
00105 
00106                         // Check
00107                         Assert.AreEqual(expectedNewSubcategory, this.functionRoleAttribute.Subcategory);
00108                 }
00109                 [Test]
00110                 public void SetMask()
00111                 {
00112                         // Preparation
00113                         Mask expectedNewMask = new Mask();
00114                         expectedNewMask.Name = "New Test Mask";
00115 
00116                         // Test 
00117                         this.functionRoleAttribute.Mask = expectedNewMask;
00118 
00119                         // Check
00120                         Assert.AreEqual(expectedNewMask, this.functionRoleAttribute.Mask);
00121                 }
00122                 [Test]
00123                 public void SetAccessView()
00124                 {
00125                         // Test
00126                         this.functionRoleAttribute.AccessView = false;
00127 
00128                         // Check 
00129                         Assert.IsFalse(this.functionRoleAttribute.AccessView);
00130                 }
00131                 [Test]
00132                 public void SetAccessAdd()
00133                 {
00134                         // Test
00135                         this.functionRoleAttribute.AccessAdd = false;
00136 
00137                         // Check 
00138                         Assert.IsFalse(this.functionRoleAttribute.AccessAdd);
00139                 }
00140                 [Test]
00141                 public void SetAccessEdit()
00142                 {
00143                         // Test
00144                         this.functionRoleAttribute.AccessEdit = false;
00145 
00146                         // Check 
00147                         Assert.IsFalse(this.functionRoleAttribute.AccessEdit);
00148                 }
00149                 [Test]
00150                 public void SetAccessDelete()
00151                 {
00152                         // Test
00153                         this.functionRoleAttribute.AccessDelete = false;
00154 
00155                         // Check 
00156                         Assert.IsFalse(this.functionRoleAttribute.AccessDelete);
00157                 }
00158                 [Test]
00159                 public void ToStringMethod()
00160                 {
00161                         Assert.AreEqual(this.expectedCategory.Name + " " + this.expectedSubcategory.Name + " " + this.expectedMask.Name, this.functionRoleAttribute.ToString());
00162                 }
00163                 [Test]
00164                 public void RestricitonsConflict_CategoryConflict()
00165                 {
00166                         bool returnStatus;
00167                         FunctionRoleAttribute newFunctionRoleAttribute = new FunctionRoleAttribute();
00168                         newFunctionRoleAttribute.Category = new FunctionRole.Category();
00169                         newFunctionRoleAttribute.Category.Name = RAIS.Common.Constants.ALL_CATEGORIES;
00170                         newFunctionRoleAttribute.Subcategory = new FunctionRole.Subcategory();
00171                         newFunctionRoleAttribute.Subcategory.Name = this.expectedSubcategoryName;
00172                         newFunctionRoleAttribute.Mask = new Mask();
00173                         newFunctionRoleAttribute.Mask.Name = this.expectedMaskName;
00174 
00175                         // Test
00176                         returnStatus = functionRoleAttribute.RestricitonsConflict(newFunctionRoleAttribute);
00177 
00178                         // Check
00179                         Assert.IsTrue(returnStatus, "RestricitonsConflict return status error:");
00180                 }
00181                 [Test]
00182                 public void RestricitonsConflict_SubcategoryConflict()
00183                 {
00184                         bool returnStatus;
00185                         FunctionRoleAttribute newFunctionRoleAttribute = new FunctionRoleAttribute();
00186                         newFunctionRoleAttribute.Category = new FunctionRole.Category();
00187                         newFunctionRoleAttribute.Category.Name = this.expectedCategoryName;
00188                         newFunctionRoleAttribute.Subcategory = new FunctionRole.Subcategory();
00189                         newFunctionRoleAttribute.Subcategory.Name = RAIS.Common.Constants.ALL_SUBCATEGORIES;
00190                         newFunctionRoleAttribute.Mask = new Mask();
00191                         newFunctionRoleAttribute.Mask.Name = this.expectedMaskName;
00192 
00193                         // Test
00194                         returnStatus = functionRoleAttribute.RestricitonsConflict(newFunctionRoleAttribute);
00195 
00196                         // Check
00197                         Assert.IsTrue(returnStatus, "RestricitonsConflict return status error:");
00198                 }
00199                 [Test]
00200                 public void RestricitonsConflict_MaskConflict()
00201                 {
00202                         bool returnStatus;
00203                         FunctionRoleAttribute newFunctionRoleAttribute = new FunctionRoleAttribute();
00204                         newFunctionRoleAttribute.Category = new FunctionRole.Category();
00205                         newFunctionRoleAttribute.Category.Name = this.expectedCategoryName;
00206                         newFunctionRoleAttribute.Subcategory = new FunctionRole.Subcategory();
00207                         newFunctionRoleAttribute.Subcategory.Name = this.expectedSubcategoryName;
00208                         newFunctionRoleAttribute.Mask = new Mask();
00209                         newFunctionRoleAttribute.Mask.Name = RAIS.Common.Constants.ALL_MASKS;
00210 
00211                         // Test
00212                         returnStatus = functionRoleAttribute.RestricitonsConflict(newFunctionRoleAttribute);
00213 
00214                         // Check
00215                         Assert.IsTrue(returnStatus, "RestricitonsConflict return status error:");
00216                 }
00217         }
00218 }